# -*- coding: utf-8 -*-

# Define here the models for your scraped items
#
# See documentation in:
# https://doc.scrapy.org/en/latest/topics/items.html

import scrapy


class MyScrapyItem(scrapy.Item):
    # define the fields for your item here like:
    # name = scrapy.Field()
    pass


class CCGV_ITEM(scrapy.Item):
    collection = table = 'CCGP'
    # 招标名称
    title = scrapy.Field()
    # 发布时间
    pubdate = scrapy.Field()
    # 地区
    city = scrapy.Field()
    # 采购人
    bidders = scrapy.Field()
    # 招标内容
    content = scrapy.Field()
    Winning_bid = scrapy.Field()
    bid_pubdate = scrapy.Field()
    address = scrapy.Field()
    price = scrapy.Field()
    type = scrapy.Field()
    dataSource = scrapy.Field()


class TestItem(scrapy.Item):
    id = scrapy.Field()
    text = scrapy.Field()


class Image360Item(scrapy.Item):
    # mysql的table名称和mongo的colletion名称
    collection = table = 'images360'
    id = scrapy.Field()
    image_url = scrapy.Field()
    title = scrapy.Field()
    thumb = scrapy.Field()
    image_path = scrapy.Field()

    def get_insert_sql(self):
        insert_sql = """
            insert into {0}(id,url,title,thumb)
            VALUES (%s,%s,%s,%s)
            ON DUPLICATE KEY UPDATE
            url = VALUES (url)      
        """.format(self.table)

        params = (
            self['id'], self['url'], self['title'], self['thumb']
        )

        return insert_sql, params


class DangBookItem(scrapy.Item):
    rank = scrapy.Field()
    name = scrapy.Field()
    comments = scrapy.Field()
    author = scrapy.Field()
    publish_time = scrapy.Field()
    publisher = scrapy.Field()
    price = scrapy.Field()


class CommandItem(scrapy.Item):
    # 无 serchEnType
    title = scrapy.Field()
    url = scrapy.Field()
    pubdate = scrapy.Field()
    author = scrapy.Field()
    content = scrapy.Field()
    dataSource = scrapy.Field()
    html = scrapy.Field()
    formats = scrapy.Field()
    id = scrapy.Field()
    updateTime = scrapy.Field()
    collectProcess = scrapy.Field()
    serverIp = scrapy.Field()


class WenshuItem(scrapy.Item):
    id = scrapy.Field()
    title = scrapy.Field()
    court_name = scrapy.Field()
    case_type = scrapy.Field()
    case_cause = scrapy.Field()
    case_number = scrapy.Field()
    province = scrapy.Field()
    litigant = scrapy.Field()
    pubdate = scrapy.Field()
    referee_time = scrapy.Field()
    html = scrapy.Field()
    content = scrapy.Field()
    updateTime = scrapy.Field()
    # html_path = scrapy.Field()
    # path = scrapy.Field()


class NewsItem(scrapy.Item):
    # 新增serchEnType
    id = scrapy.Field()
    url = scrapy.Field()
    title = scrapy.Field()
    pubdate = scrapy.Field()
    content = scrapy.Field()
    author = scrapy.Field()
    formats = scrapy.Field()
    dataSource = scrapy.Field()
    serchEnType = scrapy.Field()
    html = scrapy.Field()
    updateTime = scrapy.Field()
    collectProcess = scrapy.Field()
    serverIp = scrapy.Field()